#pragma once

/*
 * Utilities to manage the shell environment
 * Dependencies: bzbshell
 */

#include <string>
#include "bzbutil/platform.h"

namespace bzbshell {


/*
 * Returns the path to the Current Working Directory
 */

std::string get_cwd();


/*
 * Sets the Current Working Directory
 */

void set_cwd(std::string path);


/*
 * Checks if the user is privileged (Checks EUID in UNIX/Unix-like environments)
 */

bool is_privileged();


/*
 * Executes <command> and returns the exit code
 */

int pipe_open(const std::string &command);


/*
 * Executes <command> and returns the exit code and stores the output
 */

int pipe_open(const std::string &command, std::string &output);


#ifdef LINUX


/*
 * Get the shell's size
 * WARNING: This function is currently not supported on Windows
 */

void get_size(size_t *rows, size_t *columns);


#endif


#ifdef WINDOWS


/*
 * Runs the specified executable asking for administrative privilege
 * WARNING: This function is currently not supported on Linux
 */

void run_as_admin(std::string program);


/*
 * Sets the terminal's title
 * WARNING: This function is currently not supported on Linux
 */

void set_title(const std::string &title);


#endif


}
